/**
* @File           :   pagination.go
* @Time           :   2022/05/10
* @Author         :   Mz100
* @Description    :   分页
 */

package pagination

import "math"

var (
	pageSize int = 10
)

type JsonPage struct {
	Page      int         `json:"page"`
	TotalPage int         `json:"total_page"`
	Total     int64       `json:"total"`
	List      interface{} `json:"list"`
}

func GetLimitOffset(page int) (limit int, offset int) {
	limit = pageSize
	offset = (int(page) - 1) * pageSize
	return
}

func GetTotal(total int64) int {
	return int(math.Ceil(float64(total) / float64(pageSize)))
}
